home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / Mesa / src-glut / glutDestroyWindow.c < prev    next >
C/C++ Source or Header  |  1998-08-02  |  2KB  |  100 lines

  1. /*
  2.  * Amiga GLUT graphics library toolkit
  3.  * Version:  1.1
  4.  * Copyright (C) 1998 Jarno van der Linden
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Library General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Library General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Library General Public
  17.  * License along with this library; if not, write to the Free
  18.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21.  
  22. /*
  23.  * glutDestroyWindow.c
  24.  *
  25.  * Version 1.0  27 Jun 1998
  26.  * by Jarno van der Linden
  27.  * jarno@kcbbs.gen.nz
  28.  *
  29.  */
  30.  
  31.  
  32. #include <proto/intuition.h>
  33. #include <proto/exec.h>
  34. #include <proto/gadtools.h>
  35.  
  36. #include <stdlib.h>
  37.  
  38. #include "glutstuff.h"
  39.  
  40.  
  41. VOID StripIntuiMessages(struct MsgPort *mp, struct Window *win)
  42. {
  43.     struct IntuiMessage *msg;
  44.     struct Node *succ;
  45.  
  46.     msg = (struct IntuiMessage *)mp->mp_MsgList.lh_Head;
  47.  
  48.     while(succ = msg->ExecMessage.mn_Node.ln_Succ)
  49.     {
  50.         if(msg->IDCMPWindow == win)
  51.         {
  52.             Remove(msg);
  53.  
  54.             ReplyMsg(msg);
  55.         }
  56.         msg = (struct IntuiMessage *)succ;
  57.     }
  58. }
  59.  
  60.  
  61. VOID CloseWindowSafely(struct Window *win)
  62. {
  63.     Forbid();
  64.     StripIntuiMessages(win->UserPort, win);
  65.     win->UserPort = NULL;
  66.     ModifyIDCMP(win, 0L);
  67.     Permit();
  68.  
  69.     CloseWindow(win);
  70. }
  71.  
  72.  
  73. void glutDestroyWindow( int win)
  74. {
  75.     struct GlutWindow *gw;
  76.     struct Menu *menu;
  77.  
  78.     gw = stuffGetWin(win);
  79.  
  80.     stuffLinkOutWin(gw);
  81.  
  82.     ClearMenuStrip(gw->window);
  83.     menu = gw->menu;
  84.     while(menu)
  85.     {
  86.         FreeMenus(menu->FirstItem);
  87.         menu->FirstItem = NULL;
  88.         menu = menu->NextMenu;
  89.     }
  90.     FreeMenus(gw->menu);
  91.  
  92.     FreeVisualInfo(gw->vi);
  93.  
  94.     AmigaMesaRTLDestroyContext(gw->context);
  95.  
  96.     CloseWindowSafely(gw->window);
  97.  
  98.     free(gw);
  99. }
  100.